#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;
class Solution
{
public:
    int eraseOverlapIntervals(vector<vector<int>> &intervals)
    {
        if (intervals.empty())
        {
            return 0;
        }
        sort(intervals.begin(), intervals.end(), [](vector<int> a, vector<int> b) {
            return a[1] < b[1];
        });
        int size = intervals.size();
        int end = intervals[0][0];
        int ans = 0;
        for (int i = 0; i < size; i++)
        {
            if (intervals[i][0] < end)
            {
                ans++;
            }
            else
            {
                end = intervals[i][1];
            }
        }
        return ans;
    }
};
int main(int argc, char const *argv[])
{
    /* code */
    return 0;
}
